<?php
	require_once 'config.inc.php';
	if(empty($_SESSION['uid'])){
		die('请<a href="login.php">登陆</a>后再来!');
	}
	//如果是提交过来的内容则开始登陆
	if(!empty($_POST['gowrite'])){
		$sql = "insert into blogs(uid,title,content) values(?,?,?)";
		try{
			$stmt = $link->prepare($sql);
			$stmt->execute(array($_SESSION['uid'],$_POST['title'],$_POST['content']));
			echo '<script type="text/javascript">alert("写入博文成功!");</script>';
		}catch(PDOException $e){
			die('废话再一次:'.$e->getMessage());
		}
	}
?>
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title>多用户博客</title>
		<link rel="stylesheet" type="text/css" href="css/index.css"/>
		
	</head>
	<body>
		<?php include 'header.php';  ?>
		<div id="body">
			<div id="reg">
				<form action="write.php" method="post">
					<table border="0" cellspacing="10" cellpadding="0">
						<!--<colgroup>
							<col width="100" align="right"/>
							<col width="500"/>
						</colgroup>-->
						
						<tr>
							<td class="right">标题:</td>
							<td><input placeholder="请输博文标题" type="text" name="title" value="" /></td>
						</tr>
						<tr>
							<td class="right">内容:</td>
							<td><textarea name="content" rows="10" cols="90"></textarea></td>
						</tr>
						<tr>
							<td class="right">验证码:</td>
							<td>
								<input type="text" name="ucode" value="" style="width: 60px;" />
								<img src="gdcode.php" style="vertical-align: top;" onclick="this.src='gdcode.php?'+Math.random()"/>
								</td>
						</tr>
						<tr>

						<tr>
							<td class="right"></td>
							<td>
								<input id="write" name="gowrite" type="submit" value="发表"/>
								<!--<input type="submit" value="登 陆"/>-->
							</td>
						</tr>
					</table>
				</form>
			</div>
		
		</div>
			<!--<embed type="application/x-shockwave-flash" src="img/hamster.swf" width="280" height="210" id="flashID" name="flashID" bgcolor="#ccc" quality="high" flashvars="up_backgroundColor=FFFFFF" wmode="opaque" allowscriptaccess="always">-->
		<!--网站底部,写好后提取到单独页面-->
		<div id="bottom">
			版权所有 &copy; 邵阳鲲鹏五班 联系方式:QQ:88888888
		</div>
		
	</body>
</html>
